<template>
	<view class="">
		<top_nav_return :topNavTitle="topNavTitle" :returnState="returnState"></top_nav_return>
	</view>
</template>
<script>
	import Title from "@/components/title_comp.vue";
	import {
		wxLogin,
		bindinMajor
	} from "@/api/login.js";
	import {
		getMajor,
		newList
	} from "@/api/professionalChoice.js";
	import {
		setMajorInfo,
		getMajorInfo
	} from "@/common/util/index.js";

	export default {
		components: {
			Title,
		},
		data() {
			return {
				topNavTitle:'专业选择',
				returnState:false,
				loginAss: getApp().globalData.loginAss,
				imageUrl: getApp().globalData.imageUrl,
				imageUrls: getApp().globalData.imaeWd,
				majorArr: {},
				activeMajorId: "",
				num: 0,
				listData: [{
						num: 1,
						name: "介绍",
					},
					{
						num: 2,
						name: "课程",
					},
					{
						num: 3,
						name: "资料",
					},
					{
						num: 4,
						name: "服务",
					},
				],
			};
		},
		onLoad(opt) {
			console.log('接受的数据：', opt)
			// uni.showModal({
			// 	title: '123',
			// 	content: decodeURIComponent(opt.q)
			// })
		},
		mounted() {
			// this.getAll();
			// this.newList();
			const MajorInfo = getMajorInfo();
			this.activeMajorId = MajorInfo ? MajorInfo.id : "";
		},
		methods: {
			guanbi(value) {
				this.loginAss = value
			},
			// 接收选取的课程
			activeMajor(item) {
				this.activeMajorId = item.id;
				// uni.setStorageSync("MajorInfo", item);
				setMajorInfo(item);
				if (uni.getStorageSync('token')) {
					const valdsa = bindinMajor({
						majorId: getMajorInfo().id
					});
				}
				let shareUrl = ''
				try {
					shareUrl = uni.getStorageSync('shareUrl')
				} catch (err) {}
				if (shareUrl) {
					uni.reLaunch({
						url: shareUrl
					})
				} else {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}

			},
			// 获取专业科目列表
			getAll() {
				// let that = this;
				uni.request({
					// url: 'https://wendu.changyangdt.com/questionApi/courseapi/majorChoice',
					url: 'https://wendu.changyangdt.com/questionApi/resources/major/wdResourcesMajor/list',
					// url: 'https://wendu.changyangdt.com/questionApi/resources/major/wdResourcesMajor/newList',
					method: 'GET',
					// header: {
					// 	'content-type': 'application/x-www-form-urlencoded'
					// },
					success: res => {
						console.log('all:', res);
						this.majorArr = res.result;
					}
				});
				// this.majorArr = res.result;
				// console.log('all:', res.result)
			},
			// async getAll() {
			// 	const res = await getMajor();
			// 	// this.majorArr = res.result;
			// 	console.log('all:', res.result)
			// },
			async newList() {
				const res = await getMajor();
				this.majorArr = res.result;
				console.log('new:', res.result)
			},
		},
	};
</script>
<style>

</style>
<style lang="scss" scoped>

</style>
